<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateProjectAreasTable extends Migration
{
    /**
     * Run the migrations.
     * 项目区域表
     *
     * @return void
     */
    public function up()
    {
        Schema::create('project_areas', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->comment('项目名称')->nullable();
            $table->string('owner')->comment('所属业主')->nullable();
            $table->integer('department_id')->unsigned()->comment('所属部门ID')->nullable();
            $table->foreign('department_id')->references('id')->on('departments')->onDelete('set null');
            $table->integer('principal_id')->unsigned()->comment('负责人id')->nullable();
            $table->foreign('principal_id')->references('id')->on('employees')->onDelete('set null');
            $table->string('phone',20)->comment('联系电话')->nullable();
            $table->polygon('areas')->comment('区域经纬度')->nullable();
            $table->string('qy_areas',20)->comment('区域面积')->nullable();
            $table->string('girth',20)->comment('区域围长')->nullable();
            $table->integer('level')->unsigned()->comment('区域等级')->nullable();
            $table->boolean('data_state')->comment('数据状态 0未审核 1已审核')->default(0);
            $table->string('remark')->comment('备注')->nullable();
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('project_areas');
    }
}
